import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

class Imp implements Comparator<Integer> {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }
}

///最小K个数
class Solution {
    /*public int[] smallestK(int[] arr, int k) {
        int[] sum = new int[k];
        Arrays.sort(arr);
        for(int i = 0; i < k ; i++){
            sum[i] = arr[i];
        }
    return sum;
    }*/

    /*public int[] smallestK(int[] arr, int k) {
        PriorityQueue<Integer> maxheap = new PriorityQueue<>(new Imp());
        for (int i = 0;i < k;i++){
            maxheap.offer(arr[i]);
        }
        for (int i = k; i < arr.length; i++){
            if (!maxheap.isEmpty()){
                int tmp = maxheap.peek();
                if (arr[i] < tmp){
                    maxheap.poll();
                    maxheap.offer(arr[i]);
                }
            }
        }
         int[] tmp = new int[k];
        for(int i = 0 ;i< k;i++){
            tmp[i] = maxheap.poll();
        }
        return  tmp;

    }*/
    public  int[] smallestk1(int[] arr,int k){
        PriorityQueue<Integer> minheap = new PriorityQueue<>();
        for(int i = 0;i < arr.length ;i++){
            minheap.offer(arr[i]);
        }
        int[] tmp = new int[k];
        for (int i = 0;i < k; i++){

              tmp[i] = minheap.poll();

        }
        return  tmp;
    }




}